#include <stdio.h>
#include "main.h"
#include <string.h>

#define RETURN '\n'

int addcontact(FILE* file, struct contact* data, int* p_index)
{
	int i, c;
	char ret;
	if ((*p_index) > 19){
		return 1;
	} 
	else {
		printf("Enter the contact's name:");
		i = 0;
		while((c = getchar()) != '\n'){
			data[*p_index].name[i] = c;
			i++;
		}
		data[*p_index].name[i] = '\0';
		printf("Enter the contact's age:");
		scanf("%d", &(data[*p_index].age));
		scanf("%c", &ret);
		i = 0;
		printf("Enter the contact's phone number:");
		while((c = getchar()) != '\n'){
			data[*p_index].tel[i] = c;
			i++;
		}
		data[*p_index].tel[i] = '\0';
		(*p_index)++;
		printf("Contact added...\n");
		printf("You have %d contact(s).\n", (*p_index));
		
	}
	return 0;
}
